<script lang="ts" setup>
// #region 引入包, 函数和组件
import type { SearchAdviceItem } from "@/services/type";
import { inject, ref } from "vue"
import type { ProvideInject } from "../search.vue";
// #endregion

// #region // 使用模块(仓库、路由、父组件参数函数)
// 接受父组件的参数
const props = defineProps<{
  list: SearchAdviceItem[]
}>()
const search = inject<ProvideInject>('search')
// #endregion

// #region // 变量

// #endregion

// #region // 函数

// #endregion

// #region // 生命周期和vue函数

// #endregion

</script>

<template>
  <scroll-view class="advice" scroll-y v-if="list.length">
    <view
      class="advice_item"
      v-for="item in list"
      :key="item.keyword"
      @click="search?.toResult(item.keyword)"
    >{{ item.keyword }}</view>
  </scroll-view>
  <view class="empty" v-else>无建议...</view>
</template>

<style lang="scss" scoped>
.advice_item {
  height: 80rpx;
  border-bottom: 2rpx dashed #ddd;
  line-height: 78rpx;
  padding-left: 40rpx;
}
.empty {
  font-size: 40rpx;
  color: #999;
  text-align: center;
  line-height: 100rpx;
}
</style>
